#include "contacts.pb.h"

int main(){

//定义结构化对象
    contacts::contact req;
    req.set_sn(10001);
    req.set_name("小明");
    req.set_score(99.5);

    //序列化
    const std::string str = req.SerializeAsString();

    //反序列化
    contacts::contact rsp;
    bool ret = rsp.ParseFromString(str);
    if(!ret){
        std::cout << "反序列化失败" << std::endl;
        return 1;
    }

    std::cout<< rsp.sn() << "\n";
    std::cout<< rsp.name() << "\n";
    std::cout<< rsp.score() << "\n";

    return 0;
}